package fons.model.ontology.language;

import java.util.Collections;
import java.util.List;
import java.util.Set;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

public class ModifierSentenceElement extends SentenceElementMixin {
	private final Set<DimensionSentenceElement> appliedOn = Sets.newHashSet();
	private final List<DimensionSentenceElement> selectedElements = Lists.newArrayList();
	
	public ModifierSentenceElement(SentenceElement other) {
		super(other);
	}

	public Modifier get() {
		return this.get(Modifier.class);
	}

	public void applyModifier(Sentence sentence) {
		final Modifier m = get();
		m.selectElements(sentence, this);
	}
	
	public void applyOn (DimensionSentenceElement element) {
		if (!appliedOn.contains(element)) {
			element.addModifier(this);
			appliedOn.add(element);
		}
	}
	
	public List<DimensionSentenceElement> getSelectedElements() {
		return Collections.unmodifiableList(selectedElements);
	}
	
	public void selectElement(DimensionSentenceElement element) {
		this.selectedElements.add(element);
	}
}
